#include "ServerCal.hpp"
#include "TcpServer.hpp"

static void Usage(const std::string &proc)
{
    std::cout << "\nUsage: " << proc << " port\n" << std::endl; 
}

// ./ServerCal port
int main(int argc,char* argv[])
{
    if(argc != 2)
    {
        Usage(argv[0]);
        return 1;
    }

    uint16_t port = stoi(argv[1]);
    ServerCal cal;
    TcpServer *tsvp = new TcpServer(port, bind(&ServerCal::Calculator, &cal, std::placeholders::_1));

    tsvp->Init();

    tsvp->Start();

    // Request rst(315,325,'*');
    // string out;
    // rst.Serialize(&out);
    // cout<<out<<endl;

    // out = Encode(out);
    // cout<<out<<endl;

    // string content;
    // Decode(out,&content);
    // cout<<content<<endl;

    // rst.Deserialize(content);
    // cout<<rst._left<<endl;
    // cout<<rst._right<<endl;
    // cout<<rst._op<<endl;

    // Response rse(315,325);
    // string out;
    // rse.Serialize(&out);
    // cout<<out<<endl;

    // out = Encode(out);
    // cout<<out<<endl;

    // string content;
    // Decode(out,&content);
    // cout<<content<<endl;

    // rse.Deserialize(content);
    // cout<<rse._result<<endl;
    // cout<<rse._code<<endl;


    return 0;
}